#ifndef GAMEPERSENT_H
#define GAMEPERSENT_H
#include "QWidget"
#include "utils/imghelper.h"
#include "winnls32.h"
#include "utils/timemanager.h"
#include "QApplication"
#include "event/logevent.h"
#include "QDebug"
#include "utils/win32util.h"
#include "tlbbcode.h"
#include "setting.h"
#include "utils/gamemanager.h"
#include "CallBack.h"
#include "utils/gametask.h"
#include "bean/citynode.h"

class GamePersent:public BasePersent
{
    Q_OBJECT
protected:
    QWidget *widget;
    QRectF inputRectF;
    int checkAutoWayCount = 0; //记录自动寻路失败次数
    QRectF *qRectF = new QRectF();
    double blood; //血量
    double magic; //蓝量
    CityNode *checkCityNode = nullptr;
    const Scalar textStartScalar= Scalar(0, 0, 250);
    const Scalar textEndScalar = Scalar(28, 158, 255);

public:
    bool isBindGame =false; //默认未绑定游戏
    void test();

public:
   explicit GamePersent(QWidget *widget = 0);

    //绑定游戏，通过游戏的className设置游戏窗口大小及坐标
    void bindGame(QString className);

    void unbindGame();

    HWND getWindowHandle();

    //不显示其他玩家
    virtual void closeOtherRole();

    virtual void moveRoles(CityNode *cityNode, CallBack *callback, bool isWait = true);
    virtual void moveRoles(int x, int y, CallBack *callback , bool isWait = true);

    virtual bool clickDest(QString img, Scalar startScalar, Scalar endScalar, float threshold = 0, QRectF percentRectf = QRectF(0,0,1,1), bool isDoubleClick = false);

    //复活
    virtual bool resurgence();

    virtual bool clickFuncKey(QString key);
    //角色加血
    virtual void addBlood();

    virtual void addMagic();
    //加速键
    virtual void addSpeed();

   //获取游戏中的时辰
    virtual int getGameTime();

    virtual void clickNPC(QString img, Scalar startScalar, Scalar endScalar, bool isHide = true);


    virtual void clickNPC(QString img ,bool isHide = true);

    virtual void changeRole(int roleIndex);

    virtual bool goGroupCity(QString groupCityEn,QString xiaoWeiLocationImg, CallBack *callback);

    virtual void clickXiaoWei(QString enName, int cityIndex);

    virtual bool inputX(int x);

    virtual bool inputY(int y);

    virtual bool checkBuy();
    //官票不够了 帮派与城市之间跑商 银票余额不够了提示
    virtual bool checkYinPiaoHave();
    //检查商品是否售空
    virtual bool checkHasGoods(QString goodsImg, Scalar startScalar, Scalar endScalar);

    //检查是否还能继续购买商品
    virtual bool checkYinPiao();
    //检查是否银票是否购满
    virtual bool checkYininPiaoFill();
    //检查背包是否满格状态
    virtual bool checkPackageFill();

    //检查是否操作过快
    virtual bool checkOperationFast();
    //购买的商品内容改变
    virtual bool checkContentChange();
    //杀npc total 杀掉的个数
    virtual bool killNPCs(CallBack *callback, QList<QPoint*>* points = nullptr, int total =0);

    /**
     * @brief killNPC
     * @param nodeTotal 此节点处杀怪物的数量 为0则找不到怪物就表示杀完
     * @param isOnlyOne 是否只杀一个怪物
     * @return
     */
    virtual bool killNPC(int nodeTotal, bool isOnlyOne = false);

    virtual ~GamePersent();

private:
    //检查 自动寻路面板 是否打开
    bool checkOpenAutoWay();
    //被杀，需要去地府
    virtual void goHell();
    //出地府
    virtual bool outHell();

    virtual void moveByPoint(int x, int y, CallBack *callback, bool isWait);

    virtual void moveByImg(CityNode * cityNode, CallBack *callback, bool isWait);

private:
    void selectHell();

signals:
    void finish();

};

#endif // GAMEPERSENT_H
